// CubicSpline.h
#ifndef CUBICSPLINE_H
#define CUBICSPLINE_H

#include <QVector>
#include <Eigen/Dense>
#include <algorithm>
#include <limits>

class CubicSpline {
public:
    explicit CubicSpline(const QVector<double>& x, const QVector<double>& y);
    double interpolate(double x);

private:
    void calculateCoefficients();
    int findSegment(double x) const;

    QVector<double> m_x, m_y;    // 数据节点
    QVector<double> m_a, m_b, m_c, m_d; // 样条系数
    int m_n;                     // 节点数量
    bool m_coeffCalculated = false; // 计算状态标志
};

#endif // CUBICSPLINE_H
